echo "安装zookeeper"
mkdir /home/tools
cd /home/tools
yum install -y epel-release
yum install -y wget
yum install -y java-1.8.0-openjdk
wget -c https://downloads.apache.org/zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9-bin.tar.gz
tar -xzvf apache-zookeeper-3.5.9-bin.tar.gz -C /usr/local
cd /usr/local
mv apache-zookeeper-3.5.9-bin  zookeeper


cat <<END> /usr/local/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper
dataLogDir=/data/zookeeper/logs
clientPort=2181
server.1=192.168.188.251:2888:3888
server.2=192.168.188.252:2888:3888
server.3=192.168.188.253:2888:3888
END
mkdir -p /data/zookeeper/logs
echo 1 > /data/zookeeper/myid

echo "export ZOOKEEPER_HOME=/usr/local/zookeeper/" >> /root/.bash_profile
echo "export PATH=\$ZOOKEEPER_HOME/bin:\$PATH" >> /root/.bash_profile
source /root/.bash_profile

firewall-cmd --add-port=2181/tcp --permanent
firewall-cmd --add-port=2888/tcp --permanent
firewall-cmd --add-port=3888/tcp --permanent
firewall-cmd --reload
